#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int MAXN = 2e6+10;

vector<int> G[MAXN];

int dfn[MAXN],low[MAXN],scc[MAXN],sccnum,n,m,tot,stk[MAXN],top;
bool vis[MAXN];

void dfs(int x){
	low[x] = dfn[x] = ++tot;vis[x] = 1;stk[++top] = x;
	for(int i = 0;i < G[x].size();i++){
		int y = G[x][i];if(!dfn[y]) dfs(y),low[x] = min(low[x],low[y]);else if(vis[y]) low[x] = min(low[x],dfn[y]);}
	if(low[x] == dfn[x]){int y;sccnum++;do{y = stk[top--];vis[y] = 0;scc[y] = sccnum;}while(x != y);}
}

int main (){
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int a,sa,b,sb;scanf("%d %d %d %d",&a,&sa,&b,&sb);
		G[a+n*sa].pb(b+n*(sb^1));G[b+n*sb].pb(a+n*(sa^1));
	}
	for(int i = 1;i <= n<<1;i++) if(!dfn[i]) dfs(i);
	for(int i = 1;i <= n;i++) if(scc[i] == scc[i+n]) puts("IMPOSSIBLE"),exit(0);
	puts("POSSIBLE");for(int i = 1;i <= n;i++) printf("%d ",scc[i] < scc[i+n]);return 0;
}
